<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Orchid\Platform\ItemPermission;
use Orchid\Platform\Dashboard;

class PermissionServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(Dashboard $dashboard): void
    {
        // 系统权限组
        $systemPermissions = ItemPermission::group('系统')
            ->addPermission('platform.systems.roles', '角色管理')
            ->addPermission('platform.systems.users', '用户管理');
            
        // 内容管理权限组
        $contentPermissions = ItemPermission::group('内容')
            ->addPermission('platform.posts.list', '查看文章')
            ->addPermission('platform.posts.create', '创建文章')
            ->addPermission('platform.posts.edit', '编辑文章')
            ->addPermission('platform.posts.delete', '删除文章')
            ->addPermission('platform.pages.list', '查看页面')
            ->addPermission('platform.pages.create', '创建页面')
            ->addPermission('platform.pages.edit', '编辑页面')
            ->addPermission('platform.pages.delete', '删除页面')
            ->addPermission('platform.categories', '管理分类')
            ->addPermission('platform.tags', '管理标签')
            ->addPermission('platform.media', '媒体库管理');
            
        // 设置权限组
        $settingsPermissions = ItemPermission::group('设置')
            ->addPermission('platform.settings', '系统设置')
            ->addPermission('platform.menus', '菜单管理');
            
        // 注册权限到系统
        $dashboard->registerPermissions($systemPermissions)
                  ->registerPermissions($contentPermissions)
                  ->registerPermissions($settingsPermissions);
    }
}